package com.example.animaldoctor03;

import java.util.ArrayList;
import packageofjbxq.BingYuan;
import packageofjbxq.FangZiCS;
import packageofjbxq.GaiShu;
import packageofjbxq.LingChuangZZ;
import packageofjbxq.LiuXingBX;
import bingliandshuju.SingleInformationofIllnessDetail;
import commonClass.ADAQueryDiseaseInfoByDiseaseIDAction;
import commonClass.FunctionDispatcher;
import commonClass.RemoteActionsName;
import commonClass.FunctionDispatcher.IRequestCompeletListener;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import Modle.disease.Disease;
public class JBXQ  extends Activity{

	private ListView list = null ;
	private String DiseaseID = "";
	private ArrayList<Object> resultListofJBXQ = null;
	
	private String gaishu = "" , bingyuan = "" , liuxingbx = "" , lingchuangZZ = "" , fangziCS = "";
	private String [] name = {"概述" , "病原" ,"流行病学" ,"临床症状" ,"防治措施"};
	private void intitofJBXQ(){
		
		setContentView(R.layout.zhuyaozhengzhuang);
		list = (ListView)findViewById(R.id.list);
		
		ArrayAdapter<String> arry = new ArrayAdapter<String>(this , android.R.layout.simple_list_item_1 , name);
		list.setAdapter(arry);
		
		list.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				
				switch ( position ){
				
				case 0:
					Intent intentofallillness1 = new Intent(JBXQ.this , GaiShu.class);
					startActivity(intentofallillness1);
					finish();
					break;
				case 1:
					Intent intentofallillness2 = new Intent(JBXQ.this , BingYuan.class);
					startActivity(intentofallillness2);
					finish();

					break;
				case 2:

					Intent intentofallillness3 = new Intent(JBXQ.this ,  LiuXingBX.class);

					startActivity(intentofallillness3);
					finish();

					break;
				case 3:

					Intent intentofallillness4 = new Intent(JBXQ.this ,  LingChuangZZ.class);
					startActivity(intentofallillness4);
					finish();

					break;
				case 4:
					Intent intentofallillness5 = new Intent(JBXQ.this ,  FangZiCS.class);
					startActivity(intentofallillness5);
					finish();
					break;
				}
				
			}
		});
		
		

	}
	private void getIntentofJBXQ(){
		
		Intent intentofJBXQ = getIntent();
		Bundle bundleofJBXQ = intentofJBXQ.getExtras();
		DiseaseID = bundleofJBXQ.getString("shuju");

		
	}
	private ArrayList<Object> assemblyofJBXQ() {

		getIntentofJBXQ();
		ArrayList<Object> list = new ArrayList<Object>();
		list.add(DiseaseID);
		// Integer i = new Integer(10);
		// list.add(i);

		return list;
	}
	private void bindingofJBXQ(final ArrayList<Object> list){
		try{
		gaishu =((Disease)(list.get(0))).getPathologicalChange();
		bingyuan = ((Disease)(list.get(0))).getPathogen();
		liuxingbx =  	((Disease)(list.get(0))).getClinicalDiagnose();
		lingchuangZZ =((Disease)(list.get(0))).getClinicalSymptoms();
		fangziCS = ((Disease)(list.get(0))).getTherapeuticSchedule();
		
		
		SingleInformationofIllnessDetail singleInformationofIllnessDetail = SingleInformationofIllnessDetail.getInstance();
		singleInformationofIllnessDetail.setbingyuan(bingyuan);
		singleInformationofIllnessDetail.setfangziCS(fangziCS);
		singleInformationofIllnessDetail.setlingchuangZZ(lingchuangZZ);
		singleInformationofIllnessDetail.setliuxingbx(liuxingbx);
		singleInformationofIllnessDetail.setgaishu(gaishu);
		}catch(NullPointerException e){
			Builder builderofJBXQ = new AlertDialog.Builder(JBXQ.this);
			builderofJBXQ.setMessage("无数据, 请用其他功能");
			builderofJBXQ.create().show();
		}
		
		
		

	}
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		 intitofJBXQ();
		 ArrayList<Object> parasListofJBXQ = assemblyofJBXQ();
		 
		 final ArrayList<Object> resultListTofJBXQ = null;
		 
		 ADAQueryDiseaseInfoByDiseaseIDAction iActionofJBXQ = new  ADAQueryDiseaseInfoByDiseaseIDAction();
		 FunctionDispatcher functionDispacherofJBXQ = new FunctionDispatcher();
		 functionDispacherofJBXQ.exceute(RemoteActionsName.QueryDiseaseInfoByDiseaseIDAction, parasListofJBXQ, iActionofJBXQ, new IRequestCompeletListener() {

				@Override
				public void doCompelet(ArrayList<Object> resultList) {
					// TODO Auto-generated method stub
					try{
					Log.v("ZhengZhuangFZ2", "post:" + resultList.toString());
					JBXQ.this.resultListofJBXQ = resultList;
					bindingofJBXQ(resultList);
					}catch(NullPointerException e){
						Builder builderofJBXQf = new AlertDialog.Builder(JBXQ.this);
						builderofJBXQf.setMessage("返回值为空,请用其他功能");
						builderofJBXQf.create().show();
					}
				}
			},this);
		 
	}
	
	
}
